﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit" xmlns:Shazzam_Shaders="clr-namespace:Shazzam.Shaders" x:Class="FunCam.MainWindow"
        Title="MainWindow" Height="650" Width="650" Background="Black" Icon="/FunCam;component/cam.ico">
    <Window.Resources>
        <ItemsPanelTemplate x:Key="OverlayListBoxStyle">
            <VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
        </ItemsPanelTemplate>
        <DataTemplate x:Key="OverlayItemTemplate">
            <Image Source="{Binding}" Width="100" Height="80" />
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="45" />
            <RowDefinition Height="1*" />
            <RowDefinition Height="110" />
        </Grid.RowDefinitions>
        <ToolBar >
            <ComboBox x:Name="videoCapDevices" Width="125" VerticalAlignment="Center"
                        ItemsSource="{Binding Source={x:Static Controls:MultimediaUtil.VideoInputDevices}}" 
                        DisplayMemberPath="Name" Foreground="Black" Margin="0, 0, 10,0" />

            <Button Command="Controls:VideoCaptureElement.ShowPropertyPagesCommand" CommandTarget="{Binding ElementName=videoElement}" Margin="0, 0, 20,0">
                <StackPanel>
                    <Image Source="images/icons/webcam.png" />
                    <TextBlock Text="Advanced" />
                </StackPanel>
            </Button>
            <Button x:Name="SaveBtn" Click="SaveBtn_Click">
                <StackPanel>
                    <Image Source="images/icons/disk.png" />
                    <TextBlock Text="Save" />
                </StackPanel>
            </Button>
            <Button x:Name="PlayBtn" Width="40" Click="PlayBtn_Click">
                <StackPanel>
                    <Image Source="images/icons/control_play.png" Stretch="None" />
                    <TextBlock Text="Play" />
                </StackPanel>
            </Button>
            <Button x:Name="PauseBtn" Width="40" Click="PauseBtn_Click">
                <StackPanel>
                    <Image Source="images/icons/control_pause.png" Stretch="None"/>
                    <TextBlock Text="Pause" />
                </StackPanel>
            </Button>
            <ToggleButton x:Name="OverlaysBtn" Checked="OverlaysBtn_Checked" Unchecked="OverlaysBtn_Checked">
                <StackPanel>
                    <Image Source="images/icons/overlays.png" />
                    <TextBlock Text="Overlays" />
                </StackPanel>
                </ToggleButton>
            <ToggleButton x:Name="EffectsBtn" Checked="EffectsBtn_Checked" Unchecked="EffectsBtn_Checked">
                <StackPanel>
                    <Image Source="images/icons/overlays.png" />
                    <TextBlock Text="Effects" />
                </StackPanel>
            </ToggleButton>
            <ToggleButton Margin="0, 0, 10,0" x:Name="btnTimer" Click="btnTimer_Click" >
                <StackPanel>
                    <Image Source="images/icons/time.png" />
                    <TextBlock Text="Timer" />
                </StackPanel>
            </ToggleButton>
            <Button x:Name="SettingsBtn" Margin="0, 0, 30,0" Click="SettingsBtn_Click">
                <StackPanel>
                    <Image Source="images/icons/cog.png" />
                    <TextBlock Text="Settings" />
                </StackPanel>
            </Button>
            <ComboBox x:Name="EffectsList" ItemsSource="{Binding Effects}" DisplayMemberPath="Name" Width="100" VerticalAlignment="Center" SelectionChanged="EffectsList_SelectionChanged" />
        </ToolBar>
        <Border Grid.Row="1" >
            <Grid x:Name="VideoHost" >
                <Controls:VideoCaptureElement DesiredPixelWidth="640" DesiredPixelHeight="480" FPS="30" LoadedBehavior="Play"
                        VideoCaptureDevice="{Binding SelectedItem, ElementName=videoCapDevices}"
                        x:Name="videoElement" Stretch="Uniform" Effect="{Binding SelectedItem.Shader, ElementName=EffectsList}" />
                <Image Source="{Binding SelectedItem, ElementName=OverlayList}" Stretch="Uniform" x:Name="OverlayImg" />
            </Grid>
        </Border>
        <ListBox Grid.Row="2" ItemsSource="{Binding Overlays}" x:Name="OverlayList" ItemsPanel="{DynamicResource OverlayListBoxStyle}" ItemTemplate="{DynamicResource OverlayItemTemplate}" BorderThickness="4" SelectionChanged="OverlayList_SelectionChanged" />
    </Grid>
</Window>
